import process from 'process'
import * as step from '@flow-step/step-toolkit'


export async function getOssRamCertificate() {
    const flowJobToken: string | undefined =
        process.env['FLOW_JOB_TOKEN']
    if (flowJobToken == undefined) {
        const errMsg = 'missing FLOW_JOB_TOKEN'
        throw new Error(errMsg)
    }
    const ossRamStsCertificate = await step.certificate.getOssRamStsCertificate(flowJobToken, step.certificate.OssBucketType.ASSETS)
    if (ossRamStsCertificate === undefined || ossRamStsCertificate.accessKeyId === "") {
        throw new Error(`get ossRamStsCertificate but error: ${JSON.stringify(ossRamStsCertificate)}`)
    }
    return ossRamStsCertificate
}